﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using XZL.GM.Dal;
using XZL.GM.Bll;

public partial class Course_CommendEdit : AdminBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindCourseList();
            InitCommList();
           // ClientScript.RegisterStartupScript(this.GetType(), "", "GetCommIDString()", true);
        }
    }

    private void BindCourseList()
    {
        litCommList.Text = "";
        int? count = 0;
        //遍历课程类型
        List<Proc_CourseType_SelectListResult> typeList = CourseInfoBiz.GetCourseTypeList();

        for (int i = 0; i < typeList.Count; i++)
        {
            litCommList.Text += "<div style=\" color:#333;font-size:18px; \">" + typeList[i].CourseTypeName + "</div>";
            //遍历课程
            List<Proc_CourseInfo_SelectListResult> courseList = CourseInfoBiz.GetCourseList("", typeList[i].CourseTypeID, 0, 0, 1, 1000, ref count);

            for (int j = 0; j < courseList.Count; j++)
            {
            litCommList.Text += "<label style=\" color:#2a6496;font-size:15px;\"><input type=\"checkbox\" onclick=\"GetCommIDString()\"  value=" + courseList[j].CourseID + "></input>" + courseList[j].CourseName + "</label>&nbsp;&nbsp;";
            }
        }
    }


    private void InitCommList()
    {
        int cID = Convert.ToInt32(Request.QueryString["CourseID"]);

        Proc_CourseInfo_SelectInfoResult course = CourseInfoBiz.GetCourseInfo(cID);

        this.lblCommList.Value = course.RelatedCourse;
        //ClientScript.RegisterStartupScript(this.GetType(), "", "BindCommList('" + course.RelatedCourse + "')", true);


    }





    protected void btnOK_Click(object sender, EventArgs e)
    {
        int cID = Convert.ToInt32(Request.QueryString["CourseID"]);

        int courseID = Convert.ToInt32(cID);


        CourseInfoBiz.UpdateRelated(courseID, lblCommList.Value);

        Response.Redirect("CourseList.aspx");


    }





}